// components/list/orderList/orderList.js
import {
    requestUtil,
    getbaseUrl
} from "../../../utils/request"

Component({
    /**
     * 组件的属性列表
     */
    properties: {
        orderList:{
            type:Array,
            default:[]
        },
        isOnReach:{
            type:Boolean,
            default:false
        }
    },

    /**
     * 组件的初始数据
     */
    data: {

        swiperHeight: 0,
        title: ["进行中", "历史", "退单"],
        // titleActive: 0,
        userInfo: {},
        // orderList: [],
        baseUrl: "",
        // 请求的条数
        limitNum: 0

    },


    // observers: {
    //     titleActive:function(a){
    //         this.getOrderList(a)
    //         // console.log(a)
    //     }
    // },
    /**
     * 组件的方法列表
     */
    methods: {

        toShopDetail(e) {
            // console.log(e.currentTarget.dataset)
            let {
                orderid,
                openid,
                orderno
            } = e.currentTarget.dataset
            wx.navigateTo({
                url: `/pages/shopDetail/shopDetail?orderId=${orderid}&openId=${openid}&orderno=${orderno}`,
            })
        },



        // 跳转到商店列表
        toStoreList() {
            wx.switchTab({
                url: '/pages/address/address',
            })
        },

        onReach(){
            // console.log("fesfes")
            this.triggerEvent("onReach")
        }


    },

    lifetimes: {
        attached: function () {

            // 获取屏幕可用区
            let res = wx.getSystemInfoSync()


            this.setData({
                baseUrl: getbaseUrl() + "/image/",
                orderList: [],
                swiperHeight: res.windowHeight - 50
            })

            // 获取用户的信息
            wx.getStorage({
                key: "userInfo",
                success: ({
                    data
                }) => {
                    this.setData({
                        userInfo: JSON.parse(data),

                    })
                    // this.getOrderList(0)
                },
                fail: () => {
                    //    console.log("我是狗")


                }
            })

        }
    }
})